MySQL数据库转Elasticsearch

过程

  1. 安装logstash

  2. vim ./logstash/config/mysql2es.conf

    input {
      stdin {
      }
      jdbc {
      jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/database?serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true"
      jdbc_user => "root"
      jdbc_password => "root"
      jdbc_driver_library => "/Users/admin/Environment/Elasticsearch/logstash-7.13.4/config/mysql-connector-java-8.0.25.jar"
      jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
      statement => "SELECT sid as id FROM tiku"
      }
    }
    output {
      elasticsearch {
        hosts => "127.0.0.1:9200"
        index => "index1"
      document_type =>"_doc"
        document_id => "%{id}"
      }
      stdout {
        codec => json_lines
      }
    }
    
  3. ./bin/logstash -f ../config/mysql2es.conf

Copyright © rootwhois.cn 2021-2022 all right reserved,powered by GitbookFile Modify: 2023-03-05 10:55:52

results matching ""

    No results matching ""